package com.iisigroup.scan.folder;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

import com.iisigroup.scan.folder.internal.UserProjProfile;
 
/**
 * The Class DetectModificationInFolder.
 */
public class DetectModificationInFolder {
    
    /**
     * Scan now.
     */
    public void scanNow(){
       final   Map<String, UserProjProfile> map = getUserProjProfileMap();
       final  ConfigInfo config = new ConfigInfo();
       final File scanFolder = config.getScanFolder();
       final File[] fileArray = scanFolder.listFiles();
       for(int i = 0 ;fileArray != null &&  i< fileArray.length ; ++i ){
           final File acceptExam  = fileArray[i];
           //第一層僅對目錄處理
           if(acceptExam.isDirectory()){
               final UserProjProfile userProjProfile = map.get(acceptExam.getName());
               processDirectory(acceptExam ,userProjProfile);
           }
       }
    }

    protected Map<String, UserProjProfile> getUserProjProfileMap() {
        final Map<String, UserProjProfile> result = new HashMap<String, UserProjProfile>();

        return result;
    }
    /**
     * Process directory.
     *
     * @param acceptExam the accept exam
     */
    public void processDirectory(final File acceptExam ,final UserProjProfile info) {
        if(acceptExam == null || acceptExam.isFile()){
            return ;
        }
        final  String folderName = acceptExam.getName();
        final  File[] listFiles = acceptExam.listFiles();
        for(final File aFile : listFiles ){
            if(aFile.isFile()){
                //如果是檔案則是搬移檔案到該project的今日
                
            }else if(aFile.isDirectory() && aFile.getName().matches("\\d{1-4}-\\d\\d-\\d\\d")){
                //如果目錄名稱是符合2014-11-27此格式,就開始搬移至所對應porject
             
                
            }  
        }
        
    }
    
}
